﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AQMProject
{
    /// <summary>
    /// Interaktionslogik für Einrichtung.xaml
    /// </summary>
    public partial class Einrichtung : Window
    {


        private String bank = "";
        private String rsslink = "";
        private String aktie = "";
        private String symbol = "";

        public Einrichtung()
        {
            InitializeComponent();
            InitForm();
        }

        private void InitForm()
        {
            //Aktie füllen.
            //ComboBoxAktie füllen.
            AktieManager aktiemanager = new AktieManager();
            List<aktie> aktielist = aktiemanager.GetAktienList();

            foreach (aktie aktieentry in aktielist)
            {
                this.ComboBoxAktien.Items.Add(aktieentry.aktienname);
            }
            this.ComboBoxAktien.SelectedIndex = 0;

            //Bank füllen.
            //ComboBoxBank füllen.
            BankManager bankmanager = new BankManager();
            List<bank> banklist = bankmanager.getBankList();

            foreach (bank bankentry in banklist)
            {
                this.ComboBoxBank.Items.Add(bankentry.bankname);
            }
            this.ComboBoxBank.SelectedIndex = 0;
            
        }



        //Buttons
        private void Aktie_Delete(object sender, RoutedEventArgs e)
        {
            AktieManager am = new AktieManager();
            am.Delete(this.symbol);
        }

        private void Aktie_Insert(object sender, RoutedEventArgs e)
        {
            aktie aktie = new aktie
            {
                aktienkuerzel = this.aktie_kuerzel.Text.ToUpper(),
                aktienname = this.aktie_name.Text
            };

            AktieManager aktienmanager = new AktieManager();
            aktienmanager.Insert(aktie);
        }

        private void Rss_Delete(object sender, RoutedEventArgs e)
        {
            RssManager rss = new RssManager();
            rss.Delete(this.rsslink);
        }

        private void Rss_Insert(object sender, RoutedEventArgs e)
        {
        }

        private void Bewertung_Delete(object sender, RoutedEventArgs e)
        {
        }

        private void Bewertung_Insert(object sender, RoutedEventArgs e)
        {
        }

        private void Empfehlung_Delete(object sender, RoutedEventArgs e)
        {
        }

        private void Empfehlung_Insert(object sender, RoutedEventArgs e)
        {
        }

        private void updateRss(object sender, RoutedEventArgs e)
        {
            WriteRSSinDB rssdb = new WriteRSSinDB();
            rssdb.RSSUpdate();
            MessageBox.Show(rssdb.getFeedAnz().ToString()+" RSS-Feed(s) eingelesen.");
        }

        //Combbox - Selection Changed
        private void ComboBoxAktien_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.aktie = this.ComboBoxAktien.SelectedItem.ToString();
            AktieManager aktiemanager = new AktieManager();
            this.symbol = aktiemanager.GetAktienkuerzel(this.ComboBoxAktien.SelectedItem.ToString());
        }

        private void ComboBoxBank_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.bank = this.ComboBoxBank.SelectedItem.ToString();
        }

        /*
        private void ComboBoxRss_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.rsslink = this.ComboBoxRss.SelectedItem.ToString();
        }

        private void ComboBoxEmpfehlung_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.empfehlung = this.ComboBoxEmpfehlung.SelectedItem.ToString();
        }

        private void ComboBoxBedeutung_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.bedeutung = this.ComboBoxBedeutung.SelectedItem.ToString();
        }
         */

    }
}
